package cn.iocoder.yudao.hires.controller.admin.notice.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.hires.entity.NoticeInterviewDO;
import cn.iocoder.yudao.hires.service.notice.NoticeInterviewService;
import cn.iocoder.yudao.hires.vo.noticeinterview.CalendarVo;
import cn.iocoder.yudao.hires.vo.noticeinterview.NoticeInterviewSaveReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 下游-面试邀约")
@RestController
@RequestMapping("/app/notice-interview")
@Validated
public class AppNoticeInterviewController {

    @Resource
    private NoticeInterviewService noticeInterviewService;

    @PostMapping("/create")
    @Operation(summary = "发送面试邀约")
    //@PreAuthorize("@ss.hasPermission('system:notice-interview:create')")
    public CommonResult<Long> createNoticeInterview(@Valid @RequestBody NoticeInterviewSaveReqVO createReqVO) {
        return success(noticeInterviewService.createNoticeInterview(createReqVO));
    }

    /**
     * 个人面试记录   企业面试记录
     *
     * @param userId
     * @param positionId
     * @param positionName
     * @param tenantId
     * @param interviewStartTime
     * @return
     */
    @GetMapping("/list")
    @Operation(summary = "面试邀约记录")
    @TenantIgnore
    //@PreAuthorize("@ss.hasPermission('system:notice-interview:query')")
    public CommonResult<List<NoticeInterviewDO>> getNoticeInterviewList(Long userId, Integer positionId, String positionName, Long tenantId, String interviewStartTime, Long status) {
        return success(noticeInterviewService.getNoticeInterviewList(userId, positionId, positionName, tenantId, status, interviewStartTime));
    }

    @GetMapping("/num")
    @Operation(summary = "个人中心面试、投递、沟通数量")
    public CommonResult<Map<String, Long>> getNum(Long userId, Long tenantId) {
        return success(noticeInterviewService.getNum(userId, tenantId));
    }

    @PutMapping("/update")
    @Operation(summary = "面试状态修改")
    //@PreAuthorize("@ss.hasPermission('system:notice-interview:update')")
    public CommonResult<Boolean> updateNoticeInterviewStatus(Long id, Integer status) {
        noticeInterviewService.updateNoticeInterviewStatus(id, status);
        return success(true);
    }

    @GetMapping("/seek/interviewCalendar/flag")
    @Operation(summary = "求职端-面试日历--标识")
    //@PreAuthorize("@ss.hasPermission('system:notice-interview:update')")
    public CommonResult<List<CalendarVo>> SeekInterviewCalendarFlag(Long userId, String date) {
        return success(noticeInterviewService.SeekInterviewCalendarFlag(userId, null, date));
    }


    @GetMapping("/seek/interviewCalendar")
    @Operation(summary = "求职端-面试日历--数据")
    //@PreAuthorize("@ss.hasPermission('system:notice-interview:update')")
    public CommonResult<List<NoticeInterviewDO>> SeekInterviewCalendar(Long userId, String date) {
        return success(noticeInterviewService.interviewCalendar(userId, null, date));
    }

    @GetMapping("/interviewCalendar/flag")
    @Operation(summary = "招聘端-面试日历--标识")
    @TenantIgnore
    //@PreAuthorize("@ss.hasPermission('system:notice-interview:update')")
    public CommonResult<List<CalendarVo>> interviewCalendarFlag(Long tenantId, String date) {
        return success(noticeInterviewService.SeekInterviewCalendarFlag(null, tenantId, date));
    }

    @GetMapping("/interviewCalendar")
    @Operation(summary = "招聘端-面试日历--数据")
    @TenantIgnore
    //@PreAuthorize("@ss.hasPermission('system:notice-interview:update')")
    public CommonResult<List<NoticeInterviewDO>> interviewCalendar(Long tenantId, String date) {
        return success(noticeInterviewService.interviewCalendar(null, tenantId, date));
    }


}